package cn.zch.soft.util.file.write;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class OutPutTxt {
  public static void main(String[] args) {
    method1("ss");
  }
  public static void method1(String txt) {
    FileWriter fw = null;
    try {
      // 如果文件存在，则追加内容；如果文件不存在，则创建文件
      File f = new File("E:\\dd.txt");
      fw = new FileWriter(f, true);
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    PrintWriter pw = new PrintWriter(fw);
    pw.println(txt);
    pw.flush();
    try {
      fw.flush();
      pw.close();
      fw.close();
    }
    catch (IOException e) {
      e.printStackTrace();
    }
  }
}
